//
//  OtherAchievement.cpp
//  ATM Killer
//
//  Created by USoft on 8/4/14.
//
//

#include "OtherAchievement.h"
OtherAchievement::OtherAchievement() {
    this->comparedObjects = __Dictionary::create();
    CC_SAFE_RETAIN(this->comparedObjects);
    this->objective = 0;
}

OtherAchievement::~OtherAchievement() {
    Utils::safeRelease(this->comparedObjects);
}

bool OtherAchievement::init() {
    this->achievementID = -1;
    this->name = "";
    this->description = "";
    this->type = -1;
    this->effectType = -1;
    this->effectPercent = 0.0f;
    return true;
}

bool OtherAchievement::examine() {
    __Array* allKeys = this->comparedObjects->allKeys();
    for (int i = 0 ; i < this->comparedObjects->count(); i ++) {
        __Integer* key = (__Integer*)allKeys->getObjectAtIndex(i);
        __Integer* comparedObject = dynamic_cast<__Integer*>(this->comparedObjects->objectForKey(key->getValue()));
        if (comparedObject->getValue() < this->objective) {
            return false;
        }
    }
    this->status = NUM_STATUS_UNLOCKED;
    return true;
}